<%-- 
    Document   : OrderSearchResult
    Created on : 2020-4-20, 10:37:52
    Author     : zhang
--%>

<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page import="entity.Address"%>
<%@page import="dao.AddressDao"%>
<%@page import="entity.OrderInfo"%>
<%@page import="dao.OrderDao"%>
<%@page import="entity.OrderForm"%>
<%@page import="java.util.List"%>
<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>订单查询结果</h1>
        <%
            String name=(String)session.getAttribute("username");
        %>
        <div style="position: absolute;left:300px;top:50px"><a href="Member.jsp?name=<%=name%>">返回个人主页</a></div>
        <table>
                    <tr>
                        <th>订单号</th><th>订单时间</th><th>地址</th><th>收件人</th>
                        <th>书名</th><th>件数</th>
                    </tr>
                    <%
                            
                            Member member=new MemberDao().getMemberByName(name);
                            
                            List<OrderForm> orderformList=(List<OrderForm>)request.getAttribute("list");
                            for(OrderForm orderform:orderformList){
                                List<OrderInfo> orderinfoList=new OrderDao().getOrderInfo(orderform.getId());
                                Address address=new AddressDao().getAddressById(orderform.getAddressId());
                    %>
                        <tr>
                            <td><%=orderform.getId()%></td><td><%=orderform.getOrderDate()%></td>
                            <td><%=address.getAddress()%></td><td><%=address.getAddressee()%></td>
                            <td><ul>
                        <%
                                for(int i=0;i<orderinfoList.size();i++){
                                    Book book=new BookDao().getBookById(orderinfoList.get(i).getBookId());                                   
                        %>
                                            <li><%=book.getBookName()%></li>                            
                        <%
                                }
                        %>
                                </ul></td>
                                <td><ul>
                         <%
                                        for(int i=0;i<orderinfoList.size();i++){
                                                Book book=new BookDao().getBookById(orderinfoList.get(i).getBookId());
                         %>
                                    <li><%=orderinfoList.get(i).getCount()%></li>
                         <%
                                }
                         %>
                                </ul></td><td><a href="OrderInfo.jsp?orderid=<%=orderform.getId()%>">查看详情</a></td>
                          <%
                                 }
                           %>
                </table>
    </body>
</html>
